﻿using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;

namespace OrderApi.Models
{
    /// <summary>
    /// 订单实体模型
    /// </summary>
    public class Order
    {
        /// <summary>
        /// 订单ID（主键）
        /// </summary>
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }

        /// <summary>
        /// 订单编号（唯一标识）
        /// </summary>
        [Required]
        [MaxLength(50)]
        public string OrderNumber { get; set; }

        /// <summary>
        /// 订单创建日期（UTC时间）
        /// </summary>
        public DateTime OrderDate { get; set; } = DateTime.UtcNow;

        /// <summary>
        /// 客户名称
        /// </summary>
        [Required]
        [MaxLength(100)]
        public string CustomerName { get; set; }

        /// <summary>
        /// 订单总金额
        /// </summary>
        [Column(TypeName = "decimal(18,2)")]
        public decimal TotalAmount { get; set; }

        /// <summary>
        /// 订单状态（Created：已创建，Processing：处理中，Completed：已完成，Cancelled：已取消）
        /// </summary>
        [MaxLength(20)]
        public string Status { get; set; } = "Created";

        [Required]
        [Comment("标记订单是否已删除（假删除）")]
        public bool IsDeleted { get; set; } = false;

        [Comment("订单删除时间")]
        public DateTime? DeletedAt { get; set; }
    }
}